package com.ph.demo.cas;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicIntegerDemo {

    static AtomicInteger i = new AtomicInteger();


    static class AddThread extends Thread{

        @Override
        public void run() {
            i.getAndIncrement();
        }
    }

    public static void main(String[] args) throws Exception{

        Thread[] ts = new Thread[10];

        for(int i =0 ;i<10;i++){

            ts[i] = new AddThread();

        }
        for(int i=0;i<10;i++){

            ts[i].start();
        }
        for(int i=0;i<10;i++){

            ts[i].join();
        }

        System.out.println(i.get());
    }


}
